package club.zhaoliang.study;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;


//https://www.jianshu.com/p/74c12164ffca?tdsourcetag=s_pcqq_aiomsg
public class HookActivity extends AppCompatActivity {

    TextView tvToast;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hook);
        tvToast = findViewById(R.id.tvToast);

        tvToast.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(HookActivity.this, "别点啦，再点我咬你了...", Toast.LENGTH_SHORT).show();

            }
        });

    }


    static class ProxyOnClickListener implements View.OnClickListener {
        View.OnClickListener oriLis;
        public ProxyOnClickListener(View.OnClickListener oriLis) {
            this.oriLis = oriLis;
        }
        @Override
        public void onClick(View v) {
            Log.d("HookSetOnClickListener", "点击事件被hook到了");
            if (oriLis != null) {
                oriLis.onClick(v);
            }
        }
    }


}
